package com.hq.fxh.No6UerSpace.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hq.fxh.R;
import com.hq.fxh.Utils.AppConstant;
import com.hq.fxh.Utils.GlideUtils;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/20
 * @Email xlwenhao1858@sina.com
 */


public class Radapter_UserSpace_Activity extends RecyclerView.Adapter<Radapter_UserSpace_Activity.ActivityViewHolder> {


    Context context;


    @Override
    public ActivityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();

        ActivityViewHolder canPinViewHolder = new ActivityViewHolder(View.inflate(context, R.layout.item_space_activity, null));


        return canPinViewHolder;
    }

    @Override
    public void onBindViewHolder(ActivityViewHolder holder, int position) {

        if (position % 2 == 0) {
            holder.layoutItemActivityType1.setVisibility(View.GONE);
            holder.layoutItemActivityType2.setVisibility(View.VISIBLE);
        } else {
            holder.layoutItemActivityType1.setVisibility(View.VISIBLE);
            holder.layoutItemActivityType2.setVisibility(View.GONE);
        }
        GlideUtils.loadImageView(context, AppConstant.imageUrl, holder.imageItemActivity);
    }


    @Override
    public int getItemCount() {
        return 10;
    }


    class ActivityViewHolder extends RecyclerView.ViewHolder {
        protected View rootView;
        protected TextView tvItemActivityTitle;
        protected TextView tvItemActivityJiangLi;
        protected TextView tvItemActivityShare;
        protected RelativeLayout layoutItemActivityType1;
        protected TextView tvItemActivityTime;
        protected LinearLayout layoutItemActivityType2;
        protected ImageView imageItemActivity;
        protected LinearLayout newsType1;

        public ActivityViewHolder(View itemView) {
            super(itemView);
            initView(itemView);
        }


        private void initView(View rootView) {
            tvItemActivityTitle = (TextView) rootView.findViewById(R.id.tv_item_activity_title);
            tvItemActivityJiangLi = (TextView) rootView.findViewById(R.id.tv_item_activity_JiangLi);
            tvItemActivityShare = (TextView) rootView.findViewById(R.id.tv_item_activity_share);
            layoutItemActivityType1 = (RelativeLayout) rootView.findViewById(R.id.layout_item_activity_type1);
            tvItemActivityTime = (TextView) rootView.findViewById(R.id.tv_item_activity_time);
            layoutItemActivityType2 = (LinearLayout) rootView.findViewById(R.id.layout_item_activity_type2);
            imageItemActivity = (ImageView) rootView.findViewById(R.id.image_item_activity);
            newsType1 = (LinearLayout) rootView.findViewById(R.id.newsType1);
        }
    }


}
